<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>demo</title></title>
</head>
<body>
  <div id="root"></div>
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>
  <script type="text/babel">

    class Person extends React.Component{
      // Props 传值和校验
      state = {
        count: 0
      }

      static propTypes = {
        name: PropTypes.string.isRequired
      }

      static defaultProps = {
        name: "张三"
      }

      addCount = ()=>{
        this.setState({
          count: this.state.count + 1
        })
      }

      render(){
        return (<h1 onClick={this.addCount}>
          hello world{this.state.count}{this.props.name}
          </h1>)
      }
    }


    ReactDOM.render(<Person />,document.getElementById("root"))
  </script>
</body>
</html>